LanguageExt.Core

LanguageExt.Core Prelude Catch

Contents

class Prelude Source #

The @catch functions produce a CatchError or CatchValue type. These can be composed together with the Aff and Eff monads (and maybe more in the future), to create a functional-programming equivalent to exception catching and matching.

Examples

 public class TimeoutExample<RT>
     where RT : struct,
     HasTime<RT>,
     HasCancel<RT>,
     HasConsole<RT>
 {
     public static Aff<RT, Unit> main =>
         from _1 in timeout(60 * seconds, longRunning)
                  | @catch(Errors.TimedOut, unit)
         from _2 in Console<RT>.writeLine("done")
         select unit;

     static Aff<RT, Unit> longRunning =>
         (from tm in Time<RT>.now
          from _1 in Console<RT>.writeLine(tm.ToLongTimeString())
          select unit)
        .ToAff()
        .Repeat(Schedule.Fibonacci(1 * second));
 }

Methods

method CatchValue<A> @catch <A> (Error error, Func<Error, A> Fail) Source #

Catch an error if the error matches the argument provided

method CatchM<M, A> @catchM <M, A> (Error error, Func<Error, K<M, A>> Fail) Source #

Catch an error if the error matches the argument provided

method CatchError @catch (Error error, Func<Error, Error> Fail) Source #

Catch an error if the error matches the argument provided

method CatchValue<A> @catch <A> (Error error, A Fail) Source #

Catch an error if the error matches the argument provided

method CatchM<M, A> @catchM <M, A> (Error error, K<M, A> Fail) Source #

Catch an error if the error matches the argument provided

method CatchError @catch (Error error, Error Fail) Source #

Catch an error if the error matches the argument provided

method CatchValue<A> @catch <A> (int errorCode, Func<Error, A> Fail) Source #

Catch an error if the error Code matches the errorCode argument provided

method CatchM<M, A> @catchM <M, A> (int errorCode, Func<Error, K<M, A>> Fail) Source #

Catch an error if the error matches the argument provided

method CatchError @catch (int errorCode, Func<Error, Error> Fail) Source #

Catch an error if the error Code matches the errorCode argument provided

method CatchValue<A> @catch <A> (int errorCode, A Fail) Source #

Catch an error if the error Code matches the errorCode argument provided

method CatchM<M, A> @catchM <M, A> (int errorCode, K<M, A> Fail) Source #

Catch an error if the error matches the argument provided

method CatchError @catch (int errorCode, Error Fail) Source #

Catch an error if the error Code matches the errorCode argument provided

method CatchValue<A> @catch <A> (Func<Error, bool> predicate, Func<Error, A> Fail) Source #

Catch an error

method CatchM<M, A> @catchM <M, A> (Func<Error, bool> predicate, Func<Error, K<M, A>> Fail) Source #

Catch an error if the error matches the argument provided

method CatchError @catch (Func<Error, bool> predicate, Func<Error, Error> Fail) Source #

method CatchValue<A> @catch <A> (Func<Error, bool> predicate, A Fail) Source #

Catch an error if it's of a specific exception type

method CatchM<M, A> @catchM <M, A> (Func<Error, bool> predicate, K<M, A> Fail) Source #

Catch an error if the error matches the argument provided

method CatchError @catch (Func<Error, bool> predicate, Error Fail) Source #

Catch an error if it's of a specific exception type

method CatchError @catch (Error Fail) Source #

Catch all errors and return Fail

method CatchValue<A> @catch <A> (A Fail) Source #

Catch all errors and return Fail

method CatchM<M, A> @catchM <M, A> (K<M, A> Fail) Source #

Catch all errors and return Fail

method CatchM<M, A> @catchM <M, A> (Func<Error, K<M, A>> Fail) Source #

Catch all errors and return Fail

method CatchValue<A> @catchOf <E, A> (Func<E, A> Fail) Source #

where E : Error

Catch errors

method CatchM<M, A> @catchOfM <E, M, A> (Func<E, K<M, A>> Fail) Source #

where E : Error

Catch all errors and return Fail

method CatchError @catchOf <E> (Func<E, Error> Fail) Source #

where E : Error

Catch errors

method CatchValue<A> @expected <A> (Func<Expected, A> Fail) Source #

Catch expected errors

method CatchM<M, A> @expectedM <M, A> (Func<Expected, K<M, A>> Fail) Source #

Catch all errors and return Fail

method CatchError @expected (Func<Expected, Error> Fail) Source #

Catch expected errors

method CatchValue<A> @expectedOf <E, A> (Func<E, A> Fail) Source #

where E : Expected

Catch expected errors

method CatchM<M, A> @expectedOfM <E, M, A> (Func<E, K<M, A>> Fail) Source #

where E : Expected

Catch all errors and return Fail

method CatchError @expectedOf <E> (Func<E, Error> Fail) Source #

where E : Expected

Catch expected errors

method CatchValue<A> @exceptional <A> (Func<Exceptional, A> Fail) Source #

Catch exceptional errors

method CatchM<M, A> @exceptionalM <M, A> (Func<Exceptional, K<M, A>> Fail) Source #

Catch all errors and return Fail

method CatchError @exceptional (Func<Exceptional, Error> Fail) Source #

Catch exceptional errors

method CatchValue<A> @exceptionalOf <E, A> (Func<E, A> Fail) Source #

where E : Exceptional

Catch exceptional errors

method CatchM<M, A> @exceptionalOfM <E, M, A> (Func<E, K<M, A>> Fail) Source #

where E : Exceptional

Catch all errors and return Fail

method CatchError @exceptionalOf <E> (Func<E, Error> Fail) Source #

where E : Exceptional

Catch exceptional errors